#ifndef _FOOLIBC_H_
#define _FOOLIBC_H_


inline static unsigned int my_strlen(const char *str)
{
	const char *s;
	for (s = str; *s; ++s);
	return (s - str);
}

inline static char* my_strncat(char *dest, const char *src, unsigned int n)
{
	unsigned int dest_len = my_strlen(dest);
	unsigned int i;

	for (i = 0; i < n && src[i] != '\0'; i++)
		dest[dest_len + i] = src[i];
	dest[dest_len + i] = '\0';

	return dest;
}

inline static char* my_strncpy(char *dest, const char *src, unsigned int n) 
{
	unsigned int i;

	for (i = 0; i < n && src[i] != '\0'; i++)
		dest[i] = src[i];
	for (; i < n; i++)
		dest[i] = '\0';

	return dest;
}


inline static void my_itoa(long value, char *dest) 
{
	const static char hex_helper[16] = "0123456789abcdef";
	register int i;

	/* Print each character of the hexadecimal number. This is a very inefficient
	   way of printing hexadecimal numbers. It is, however, very compact in terms
	   of the number of source code lines. */
	for (i = 15; i >= 0; i--) {
		//		outb(0xe9, hex_helper[(value >> (i * 4))&15]);
		dest[15 - i] = hex_helper[(value >> (i * 4))&15];
	}
}




#endif
